//
//  SYPiGaiViewController.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/25.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYPiGaiViewController.h"
#import "BanJiTopView.h"
#import "SYDaiPiGaiView.h"
#import "SYYuejuanYiPiGaiView.h"
#import "SYPiCuoFanKuiView.h"
#import "SYTopBtnView.h"



@interface SYPiGaiViewController () <BanJiTopViewSelectedDelegate>
@property (nonatomic, strong) BanJiTopView *banJiTopView;
@property (nonatomic, strong) SYDaiPiGaiView *daipiGaiView;
@property (nonatomic, strong) SYYuejuanYiPiGaiView *yipigaiView;//已经批改
@property (nonatomic, strong) SYTopBtnView *topView;//顶部导航
@property (nonatomic, strong) SYDaiPiGaiView *zypgView;//作业批改
@property (nonatomic, strong) SYPiCuoFanKuiView *pcfkView;//批错反馈

@end

@implementation SYPiGaiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
//    self.view.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
    [self initUpKit];
}

- (void)initUpKit {
    
    [self.view addSubview:self.topView];
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.equalTo(self.view);
        make.height.mas_equalTo(45);
    }];
    
    [self.view addSubview:self.daipiGaiView];
    [self.daipiGaiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view.mas_right).offset(-14);
        make.bottom.equalTo(self.view.mas_bottom).offset(-14);
    }];
    
    [self.view addSubview:self.yipigaiView];
    [self.yipigaiView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view.mas_right).offset(-14);
        make.bottom.equalTo(self.view.mas_bottom).offset(-14);
    }];
    
    
    [self.view addSubview:self.pcfkView];
    [self.pcfkView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topView.mas_bottom);
        make.left.equalTo(self.view);
        make.right.equalTo(self.view.mas_right).offset(-14);
        make.bottom.equalTo(self.view.mas_bottom).offset(-14);
    }];
    
    __weak typeof(self) weakSelf = self;
    self.topView.block = ^(NSInteger index) {
        if (index == 0) {//待批改
            weakSelf.yipigaiView.hidden = YES;
            weakSelf.daipiGaiView.hidden = NO;
            weakSelf.pcfkView.hidden = YES;
        } else if (index == 1) {//已批改
            weakSelf.yipigaiView.hidden = NO;
            weakSelf.daipiGaiView.hidden = YES;
            weakSelf.pcfkView.hidden = YES;
            [weakSelf.yipigaiView requestDataList];
        } else {//作业批改
            weakSelf.yipigaiView.hidden = YES;
            weakSelf.daipiGaiView.hidden = YES;
            weakSelf.pcfkView.hidden = NO;
            [weakSelf.pcfkView requestDataPage:1];
        }
    };
    
    
}






#pragma mark - BanJiTopViewSelectedDelegate
//待批改
- (void)leftButtonClick {
    _yipigaiView.hidden = YES;
    _daipiGaiView.hidden = NO;
}
//已批改
- (void)rightButtonClick {
    _yipigaiView.hidden = NO;
    _daipiGaiView.hidden = YES;
    [_yipigaiView requestDataList];
}
-(void)timeButtonClick{
    
    _yipigaiView.hidden = YES;
    _daipiGaiView.hidden = NO;
}

#pragma mark- set
- (BanJiTopView *)banJiTopView {
    if (!_banJiTopView) {
        _banJiTopView = [[BanJiTopView alloc] init];
        _banJiTopView.delegate = self;
        _banJiTopView.timeButton.hidden = YES;
        [_banJiTopView.weiJieYeButton setTitle:@"待批改" forState:UIControlStateNormal];
        [_banJiTopView.jieYeButton setTitle:@"已批改" forState:UIControlStateNormal];
//        [_banJiTopView.timeButton setTitle:@"练习册批改" forState:UIControlStateNormal];
        _banJiTopView.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
    }
    return _banJiTopView;
}
//顶部导航
- (SYTopBtnView *)topView {
    if (!_topView) {
        _topView = [[SYTopBtnView alloc] initWithDataNameArr:@[@"待批改",@"已批改",@"作业批改"] widt:0.3333];
    }
    return _topView;
}



- (SYDaiPiGaiView *)daipiGaiView {
    if (!_daipiGaiView) {
        _daipiGaiView = [[SYDaiPiGaiView alloc] init];
    }
    return _daipiGaiView;
}
- (SYDaiPiGaiView *)zypgView {
    if (!_zypgView) {
        _zypgView = [[SYDaiPiGaiView alloc] init];
        _zypgView.hidden = YES;
    }
    return _zypgView;
}

- (SYPiCuoFanKuiView *)pcfkView {
    if (!_pcfkView) {
        _pcfkView = [[SYPiCuoFanKuiView alloc] init];
        _pcfkView.hidden = YES;
    }
    return _pcfkView;
}



//已经批改
- (SYYuejuanYiPiGaiView *)yipigaiView {
    if (!_yipigaiView) {
        _yipigaiView = [[SYYuejuanYiPiGaiView alloc] init];
    }
    _yipigaiView.hidden = YES;
    return _yipigaiView;
}

@end
